import * as ActionTypes from './ActionTypes.js';
import axios from 'axios';


const Data = {
    async getApi(ajaxCfg){
        let data = await axios.get(ajaxCfg.url,{params:ajaxCfg.cfg},
        {
            headers: ajaxCfg.headers
        })
        return data;
    }
}

export const getList = (text,aData) =>{
    return {
        type:ActionTypes.GET_LISTS,
        text:text,
        data:aData
    }
}
export const getApi = (text,ajaxCfg,dispatch,ulList) =>{
    return {
        type:ActionTypes.GET_API,
        text:text,
        ajaxFn:Data.getApi(ajaxCfg).then((res)=>{
            dispatch(getList('发送请求1',[...ulList,...res.data.data]));
            // dispatch({
            //     type:ActionTypes.GET_LIST,
            //     data:res.data
            // });
        })
    }
}
